﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccessLayer.DAL
{
    public class AucQuestionAnswer
    {
        public static Auction GetAllQuestionByAucID(int auctionID)
        {
            using (var context  = new ReverseAuctionEntities())
            {
                var result = context.Auctions.Include("AuctionQuestionAnswers").Include("AuctionQuestionAnswers.User").SingleOrDefault(u => u.ID == auctionID);
                return result;
            }
        }

        public static void AddComment(AuctionQuestionAnswer comment)
        {
            using (var context = new ReverseAuctionEntities())
            {
                comment.IsQuestionApproved = true; //mac dinh admin khong can phai duyet
                context.AuctionQuestionAnswers.AddObject(comment);
                context.SaveChanges();
            }
        }
    }
}
